package mypackage;

import java.util.Scanner;

public class testclass {
    public static void main(String[] args) {
        int[] arr = {11, 22, 33, 44, 55};
        printarr(arr);
        System.out.println();
        int max = getarrmax(arr);
        System.out.println(max);
        if (arrfind(arr, 10)) System.out.println("find " + 10 + " ok");
        else System.out.println("find " + 10 + " false");
        int[] arrb = copyofarr(arr, 0, arr.length);
        for (int i : arrb) {
            System.out.print(i + " ");
        }
        double price=1500.0;
        price=getprice(price,6,"经济舱");
        System.out.println(price);
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入机票的原价");
        price=sc.nextDouble();
        System.out.println("请输入当前的月份");
        int month=sc.nextInt();
        System.out.println("请输入机票的类型,经济舱or头等舱");
        String lei=sc.next();
        price=getprice(price,month,lei);
        System.out.println(price);
    }

    private static void getPrintln(int max) {
        System.out.println(max);
    }

    public static void printarr(int[] arr) {
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
            if (i != arr.length - 1) System.out.print(",");
        }
        System.out.print("]");
    }

    public static int getarrmax(int[] arr) {
        int mx = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (mx < arr[i]) mx = arr[i];
        }
        return mx;
    }

    public static boolean arrfind(int[] arr, int flag) {
        for (int i = 0; i < arr.length; i++) {
            if (flag == arr[i]) return true;
        }
        return false;
    }

    public static int[] copyofarr(int[] arr, int from, int to) {
        int len = to - from;
        int[] newarr = new int[len];
        for (int i = from, j = 0; i < to; i++, j++) {
            newarr[j] = arr[i];
        }
        return newarr;
    }
    public static double getprice(double preprice,int month,String lei){
        if(month>=5&&month<=10){
            if(lei=="头等舱"){
                return preprice*9.0;
            }else{
                return preprice*8.5;
            }
        }else if((month>=1&&month<=4)||(month>=11&&month<=12)) {
            if(lei=="头等舱"){
                return preprice*7.0;
            }else{
                return preprice*6.5;
            }
        }else {
            System.out.println("非法的月份");
            return 0.0;
        }
    }
}
